import Vue from 'vue'
import Router from 'vue-router'
import homeRouter from "./modules/home";
import bookingRouter from "./modules/booking";
import repairRouter from "./modules/repair";
import mineRouter from "./modules/mine";

Vue.use(Router);

// 解决点击路由跳转相同地址报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

export const constantRouterMap = [
    // {
    //   path: '/login',
    //   name: 'login',
    //   component: () => import('@/views/login/index'),
    //   hidden: true
    // },
    homeRouter,
    bookingRouter,
    repairRouter,
    mineRouter,
    {
        path: '/',
        redirect: '/home/index',
        hidden: true
    }
];

export default new Router({
    mode: 'history',
    base: '/app/',
    scrollBehavior: () => ({y: 0}),
    routes: constantRouterMap
})